program FastSlowSum;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
  Sum=class
    N,s1,s2: integer;
    procedure sum; virtual; abstract;
  end;
  SlowSum=class(Sum)
    procedure sum; override;
  end;
  FastSum=class(Sum)
    procedure sum; override;
  end;
  procedure SlowSum.sum;
  var
    i: integer;
  begin
    s1:=0;
    for i:=1 to N do
    begin
      s1:=s1+i;
    end;
    writeln(s1);
  end;
  procedure FastSum.sum;
  begin
    s2:=((N*(N+1)) div 2);
    writeln(s2);
  end;
var
  s1,s2: sum;
  N,a,i: integer;
begin
  readln(N);
  s1:=SlowSum.Create;
  s1.N:=N;
  s1.sum;
  s2:=FastSum.Create;
  s2.N:=N;
  s2.sum;
  readln;
end.
